package com.ss.sdg.methodcalling;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.TypeDeclaration;

import com.ss.sdg.SDG;

import ss.pku.Scope.SourceFileScope;
import ss.pku.util.ASTUtil;
import ss.pku.util.GlobalContainer;

/**
 * @author lijuan wang
 */
@SuppressWarnings("unused")
public class MethodCallGraphTest {
	
	public static void  Run(String path){
		MethodCallGraph g=null;
		MethodCallBuilder cgb=new MethodCallBuilder();
		//call liang wei
		ArrayList<SourceFileScope> sfss  = ASTUtil.createASTs(path);
		for(SourceFileScope src:sfss)
		{
			CompilationUnit result = (CompilationUnit) src.getAstTree();
			if(result.getProblems().length>0){
				System.out.println("the test case has problems:");
				for(IProblem pro:result.getProblems()){
					System.out.println(pro.getMessage());
				}
				return;
			}
			cgb.getCompilationUnit().put(src.getFileName(), result);
		}
		for(String key:cgb.getCompilationUnit().keySet()){
			cgb.getCompilationUnit().get(key).accept(cgb);
		}
		SDG.methodCallGraphs=cgb.getMethodCallGraphs();
	}
}

